(*
  https://www.rfc-editor.org/rfc/rfc9421#appendix-B
*)
open Alcotest
(* open Seppo_lib *)

module Ty = struct
  open Tyre
  let tc_int () =
    let ir = compile int in
    "-12" |> exec ir |> Result.get_ok |> check Alcotest.int __LOC__ (-12);
    (-12) |> eval int |> check string __LOC__ "-12"

  (* https://www.rfc-editor.org/rfc/rfc9651#name-abnf *)
  let tc_rfc9651 () =
    let _DQUOTE = char '"' in
    let _sf_integer = Tyre.int in
    let _sf_string = _DQUOTE *> pcre "([a-z])*" <* _DQUOTE in
    {|"uhu"|} |> exec (compile _sf_string) |> Result.get_ok |> check string __LOC__ "uhu";
    "uhu" |> eval _sf_string |> check string __LOC__ {|"uhu"|};
    ()
end

let set_up () =
  Unix.chdir "../../../test/"

let () =
  run
    "seppo_suite" [
    __FILE__ , [
      "set_up",              `Quick, set_up;
      "Ty.tc_int",           `Quick, Ty.tc_int;
      "Ty.tc_rfc9651",       `Quick, Ty.tc_rfc9651;
    ]
  ]
